<?php

class CA_Statistics
{
	private $db;
	
	public function register()
	{
		if(!$_COOKIE['clicked'])
		{
			$db = &$GLOBALS['sql'];
			
			$values = array(
				$_SERVER['REMOTE_ADDR'],
				$_SERVER['HTTP_USER_AGENT'],
				$_SERVER['HTTP_REFERRER']
			);
			
			$sql  = "INSERT INTO `clicks` (`ip`, `user_agent`, `referrer`, `timestamp`)";
			$sql .= "VALUES ";
			$sql .= "('{$db->escape($values[0])}', '{$db->escape($values[1])}', '{$db->escape($values[2])}', NOW())";
			
			$q = $db->query($sql);
			
			if(!$q)
			{
				if($GLOBALS['hc']->issetHook("CA_LOGGING"))
				{
					$GLOBALS['CA_Logging']->log("CA_Sitestats", "Error: " . mysql_error());
				}
			}
			
			setcookie("clicked", 1, 60);
		}
	}
}

?>